// Created by WXX on 2021/9/26 9:52
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

/**
 * 执行用时：0 ms, 在所有 C++ 提交中击败了100.00%的用户
 * 内存消耗：5.6 MB, 在所有 C++ 提交中击败了99.52%的用户
 */
class Solution {
public:
    string convertToBase7(int num) {

        if (!num) return "0";

        string res;
        bool sign = num < 0;
        int n = abs(num);
        while (n) {
            res += n % 7 + '0', n /= 7;
        }
        reverse(res.begin(), res.end());
        if (sign) res = '-' + res;
        return res;
    }
};

int main() {

    cout << Solution().convertToBase7(100) << endl;  // 202
    cout << Solution().convertToBase7(-7) << endl;  // -10

    return 0;
}
